package com.extremeforce.adapter;

import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.extremeforce.R;
import com.extremeforce.db.DBMaster;
import com.extremeforce.module.DeSubscribeActivity;

public class SubscribeListAdapter extends BaseAdapter{

	private ArrayList<HashMap<String,String>> list;
	private Context context;
	public SubscribeListAdapter(Context context,ArrayList<HashMap<String,String>> list){
		this.context = context;
		this.list = list;
	}
	
	public int getCount() {
		return list.size();
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(context);
		convertView = inflater.inflate(R.layout.subscribeitem,null);
		ImageView imageView = (ImageView) convertView.findViewById(R.id.goodsImage);
		TextView textView = (TextView)convertView.findViewById(R.id.subscribeTime);
		
		imageView.setImageBitmap(getRes("cjx_"+list.get(position).get("GOODS_ID")));
		
		
		
		textView.setText(list.get(position).get("GOODS_NAME"));
		
		return convertView;
		
	}
	
	public Bitmap getRes(String name){
		ApplicationInfo appInfo = context.getApplicationInfo();
		int resID = context.getResources().getIdentifier(name,"drawable",appInfo.packageName);
		return BitmapFactory.decodeResource(context.getResources(),resID);
	}	
	
}









